package com.example.rabbitmq_customer1.mq;

import com.alibaba.fastjson.JSONObject;
import com.example.rabbitmq_common.config.RabbitMQConfigConstants;
import com.example.rabbitmq_common.vo.UserVo;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;

/**
 * @ClassName listener
 * @Description TODO
 * @Author gql
 * @Date 2023/3/14 13:37
 **/
@Component
public class ConsumerListener {

   /* @RabbitHandler
    public void processMessage1(@Payload UserVo vo){
        System.out.println("processMessage1====>消费者从rabbitMQ服务端消费消息：" + vo.toString());
    }
    @RabbitHandler
    public void processMessage2(@Payload Map map){
        System.out.println("processMessage2===>消费者从rabbitMQ服务端消费消息：" + map.toString());
    }*/

    @RabbitListener(queues = {RabbitMQConfigConstants.RABBITMQ_DEMO_TOPIC})
    public void receiver(@Payload UserVo vo) {

        System.out.println("processMessage1====>消费者从rabbitMQ服务端消费消息：" + vo.toString());

    }
}
